var express = require('express');
var router = express.Router();
var http = require('http');

var options = {
	host: '121.41.160.43',
	port: 30001,
	path:'',
	headers:{},
	method:''
};

/* GET home page. */
router.get('/*', function(req, res, next) {

	var options = {
		host: '121.41.160.43',
		port: 30001,
		path: req.path,
		headers:req.headers,
		method:'GET'
	};

	http.get(options, function (res2) {
        res2.setEncoding('utf8');
        res2.on('data', function (data) {
            dataTtal += data;
        });
        res2.on('end', function () {
            res2.setEncoding('utf8');
            res.writeHead(res.statusCode, res.headers);
            res.end(dataTtal);
        });
        res2.on('error', function () {
        });
    }).on('error', function (e) {

    });


});
router.post('/*', function(req, res, next) {
	var options = {
		host: '121.41.160.43',
		port: 30001,
		path: req.path,
		headers:req.headers,
		method:'POST'
	};

	http.get(options, function (res2) {
        res2.setEncoding('utf8');
        res2.on('data', function (data) {
            dataTtal += data;
        });
        res2.on('end', function () {
            res2.setEncoding('utf8');
            res.writeHead(res.statusCode, res.headers);
            res.end(dataTtal);
        });
        res2.on('error', function () {
        });
    }).on('error', function (e) {

    });
});


module.exports = router;